import React, { Component } from 'react';
import ACTIONS from '../../redux/actions';
import { connect } from 'react-redux';

class DigitButton extends Component {
    state = {  } 


    render() { 
        return (<button onClick={() => this.props.add_digit(this.props.value)}>
            {this.props.value}
        </button>);
    }
}

const mapDispatchToProps = {
    add_digit: digit => {
        return {
            type: ACTIONS.ADD_DIGIT,
            value: digit,
        }
    },
}

export default connect(null, mapDispatchToProps)(DigitButton);